#include<stdio.h>
#include<stdlib.h>

typedef struct node{
	int data;
	struct node *next;
}*list;
void Create_Link(list head){
    if(head==NULL){
        head = (struct node *)malloc(sizeof(struct node));
        head->next=NULL;
    }
    int data;
    scanf("%d",&data);
    while(data!=-1){
        // getchar();
        list s=(struct node *)malloc(sizeof(struct node));
        s->data=data;
        s->next=head->next;
        head->next=s;
        scanf("%d",&data); 
    }
}
int findk(list list, int k){
	struct node *first = list,  *second = list;
	int i = 0;
	while(i < k && first->next != NULL){		//第一个指针先走k步 
        first = first->next; 
        i++;
	}
    if(i < k){									//整个链表长度小于k，直接返回0 
        return 0;
    }
    else{
        while(first != NULL){		//第一个指针走到头，第二个指针就是倒数第k个数 
            first = first->next;
            second = second->next;
        }
        printf("%d", second->data);
        return 1; 
	} 
} 
int main(){
    list head=NULL;
    Create_Link(head);
    findk(head,1);
    return 0;
}